//
// Created by Administrator on 2019/12/10.
//

#ifndef CPPDEMO_VIRTUALBASECLASSTEST_H
#define CPPDEMO_VIRTUALBASECLASSTEST_H

#include <iostream>
//虚继承只保留一份基类数据，防止冗余
using namespace std;

class A{
public:
    A(){
        cout<<"A()"<<endl;
    }
    ~A(){
        cout<<"~A()"<<endl;
    }

protected:
    int a;
};

class B : virtual public A{
public:
    B(){
        cout<<"B()"<<endl;
    }
    ~B(){
        cout<<"~B()"<<endl;
    }

protected:
    int b;
};

class C : virtual public A{
public:
    C(){
        cout<<"C()"<<endl;
    }
    ~C(){
        cout<<"~C()"<<endl;
    }

protected:
    int c;
};
#endif //CPPDEMO_VIRTUALBASECLASSTEST_H
